package com.suyang.syt.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.suyang.syt.auth.AuthClass;
import com.suyang.syt.model.OperateLog;
import com.suyang.syt.model.dto.AjaxObj;
import com.suyang.syt.model.dto.PagerEasyUI;
import com.suyang.syt.service.interfaces.OperateLogService;
import com.suyang.syt.util.StringUtil;

/** 日志信息管理 */
@Controller
@RequestMapping("/admin/operateLog")
@AuthClass
public class AdminOperateLogController {

	@Autowired
	private OperateLogService operateLogService;

	@RequestMapping(value = "/list", method = RequestMethod.GET)
	public String list() {
		return "operateLog/list";
	}

	@RequestMapping(value = "/list", method = RequestMethod.POST)
	@ResponseBody
	public PagerEasyUI<OperateLog> list(HttpServletRequest request, int page, int rows, String sort, String order, String isException, OperateLog operateLog) {
		try {
			String createDate1 = request.getParameter("createDate1");
			String createDate2 = request.getParameter("createDate2");
			return operateLogService.listByEasyUI(page, rows, sort, order, isException, operateLog, createDate1, createDate2);
		} catch (Exception e) {
			return null;
		}

	}

	@RequestMapping(value = "/delete", method = RequestMethod.POST)
	@ResponseBody
	public AjaxObj delete(HttpServletRequest request, String ids) {
		try {
			return operateLogService.delete(ids);
		} catch (Exception e) {
			return new AjaxObj(0, StringUtil.ERROR_MSG);
		}
	}

}